//
//  User.swift
//  foreign_swift
//
//  Created by 黄敦仁 on 15/4/18.
//  Copyright (c) 2015年 hdr. All rights reserved.
//

import Foundation

class User: SQLiteDataBase {
    
    /**
        sqlite数据库的主键
    */
    var userId:Int!
    /**
        用户的邮箱
    */
    var email:String!
    /*
        服务器中数据的id，由服务器下发
    */
    var serverId:Int64!
    
    /**
        用户类型，取Const中的USER_TYPE值
    */
    var userType:Int!
    
    var height:Int!
    
    var gender:Int!
    
    var birthday:Date!
    
    var nickName:String!
    
    var accountName:String!
    
    var avatar:String!
    
    var name:String!{
        if userType == Const.USER_TYPE_MASTER {
            return accountName
        }
        return nickName
    }
    
    static var tableName:String{
        return "user"
    }
    
    static var tableColumnTypes:[(SQLColumnName, SQLColumnType, SQLColumnState)]{
        return [
            ("userId",  .INTEGER,       .PrimaryKeyAutoincrement),
            ("email",.VARCHAR(80),      .NotNull),
            ("serverId",  .BIGINT,      .None),
            ("userType",  .INTEGER,     .None),
            ("height",  .INTEGER,       .None),
            ("gender",  .INTEGER,       .None),
            ("nickName",  .VARCHAR(80),       .None),
            ("accountName",  .VARCHAR(80),       .None),
            ("avatar",  .VARCHAR(80),       .None),
            ("birthday",  .DATE,       .None)
        ]

    }
}